package com.learn.springlearn.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.learn.springlearn.constant.CarEnum;
import lombok.Data;
import org.springframework.context.annotation.Primary;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

@Document(indexName = "car")
@Data
public class CarDocument {



//    @Field(type = FieldType.Keyword,fielddata = true)
    private String name;

    @Id
    private Integer carId;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
//    @Field(format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
//    @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8" )
    private Date beginTime;



    private CarEnum car;

    @JSONField(name = "carStatus")
    public String getCarStatus(){
        return car == null? null:car.getDesc();
    }
}
